package com.cuijq.darklunch.v1;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Data;

/**
 * @author by CuiJQ
 * @Classname DarkLaunch
 * @Description DarkLaunch Description
 * @Date 2021/6/1 14:58
 */
@Data
public class DarkRule {

  private Map<String, DarkFeature> darkFeatures = new HashMap<>();

  public DarkRule(DarkRuleConfig darkRuleConfig) {
    List<DarkRuleConfig.DarkFeatureConfig> darkFeatureConfigs = darkRuleConfig.getFeatures();
    for (DarkRuleConfig.DarkFeatureConfig darkFeatureConfig : darkFeatureConfigs) {
      darkFeatures.put(darkFeatureConfig.getKey(), new DarkFeature(darkFeatureConfig));
    }
  }

  public DarkFeature getDarkFeature(String featureKey) {
    return darkFeatures.get(featureKey);
  }
}
